package com.zq.learing.sort;

/**
 * @Author: zhaoqi
 * @Date: 2020/4/26 0:54
 * @Version 1.0
 */

public class Pocker {

    public static void main(String[] args) {
        Pocker pocker = new Pocker();
        pocker.shuffle();
        Card card = pocker.deal(1);


        Card  card1 = pocker.new Card("红桃",3);
        card1.toString();

        System.out.println(card);
        System.out.println(card1);

        new Card2("黑桃",4);

        //`Thread


    }


    private static String[] suites = {"黑桃","红桃","梅花","方片"};
    private static int faces[] = {1,2,3,4,5,6,7,8,9,10,11,12,13};
    public Card[] cards;
    public Pocker(){
        cards = new Card[52];
        for (int i = 0 ; i < suites.length ; i++){
            for (int i1 = 0; i1 < faces.length; i1++) {
                cards[i*13 +i1]  = new Card(suites[i],faces[i1]) ;
            }
        }
    }

    /*
    *  洗牌
    * */

    public void shuffle(){
        for (int i = 0,len = cards.length; i<len ; i++) {
            int index = (int) (Math.random()*len);
            Card temp = cards[index];
            cards[index] = cards[i];
            cards[i] =temp;
        }
    }

    public Card deal( int index){
        return cards[index];
    }


    public   class Card{
        private String suite;
        private int face;

        public Card(String suite, int face) {
            this.suite = suite;
            this.face = face;
        }

        @Override
        public String toString() {
            return "Card{" +
                    "suite='" + suite + '\'' +
                    ", face=" + face +
                    '}';
        }
    }

    public static  class Card2{
        private String suite;
        private int face;

        public Card2(String suite, int face) {
            this.suite = suite;
            this.face = face;
        }

        @Override
        public String toString() {
            return "Card{" +
                    "suite='" + suite + '\'' +
                    ", face=" + face +
                    '}';
        }
    }


}
